home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0044_Definitive ODBC-Access 2.0 access.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-24  |  3.7 KB  |  83 lines

  1.  
  2. Here is my most straight forward explanation of how to
  3. connect your Delphi application to an Access 2.0 database.  With this 
  4. method, I have connected to Access 2.0 databases, and been able to read and 
  5. write records to my hearts content.  NOTE: You MUST have the proper ODBC 
  6. drivers.  If you don't, this will not work!
  7.  
  8. REQUIRED DRIVERS:
  9.       ODBCJT16.DLL   dated 11/18/94 or later
  10.       ODBCINST.DLL   dated 08/17/94 or later
  11.       ODBCCTL16.DLL  dated 11/18/94 or later
  12.       MSAJT200.DLL      dated 11/18/94 or later
  13.       MSJETERR.DLL   dated 11/18/94 or later
  14.       MSJETINT.DLL      dated 11/18/94 or later
  15.  
  16. To the best of my knowledge, these are all of the drivers that are above and 
  17. beyond your base ODBC drivers.  You should be able to obtain these from MS 
  18. on their FTP/WWW site, however I do not know exact directories.  My company
  19. is a MS Solutions Provider, and we obtained these drivers on one of the many 
  20. CDs we received from MS.
  21.  
  22. Now for the meat of this posting:
  23.  
  24. To access a database via ODBC, you must first create an ODBC connection to 
  25. the database.
  26.    1) Open Control Panel, and then select ODBC.
  27.    2) When the Data Sources dialog appears, select Add.
  28.    3) If you have installed all of the drivers properly, you should see the 
  29. following Access drivers:
  30.          Access Data (*.mdb)
  31.          Access Files(*.mdb)
  32.          Microsoft Access Driver (*.mdb)
  33.    4) The one you MUST choose is the third one, Microsoft Access Driver.  
  34. Choosing any of the others will not work.
  35.    5) You will then be presented with the ODBC Microsoft Access 2.0 Setup 
  36. dialog.  Fill this in with the information regarding the database to which 
  37. you wish to connect.
  38.    6) Save the settings and then exit all the way out of Control Panel.
  39.  
  40. After having made a proper connection to the database with ODBC, the rest is 
  41. quite simple.
  42.    7) Open BDE Config.
  43.    8) Choose New ODBC Driver.
  44.    9) Give your SQL link a name
  45.    10) From the Default ODBC Driver combo box, you must choose the Microsoft 
  46. Access Driver, just the same as you did in the ODBC setup.  Do not choose 
  47. Access Data/Files drivers.
  48.    11) If everything is setup properly, the name of your database should 
  49. appear in the Default Data Source Name combo box.  Select it now.
  50.    12) Select OK, you will be back to the main dialog for BDE Config.  
  51. Select the aliases tab.
  52.    13) Create a new alias, using the SQL link that you just created (it will 
  53. start with ODBC_) as your Alias Type.
  54.    14) Now save and exit from BDE Config.
  55.  
  56. You should now be able to get to you Access 2.0 database with both read and 
  57. write instructions.
  58.  
  59. And finally...
  60. I must say that having got to Access, via ODBC, you will probably wish you 
  61. hadn't.  It is sssllllooowww.  Anytime we start adding layers, it gets
  62. slower and slower.  Normally, I would recommend staying away from VB like 
  63. the plague (I'm an old C++ hacker of many years, and the term BASIC makes me 
  64. shudder).  However, at this point in time, the best way to use Access 
  65. databases is through either Access or VB.  Microsoft is very close-mouthed 
  66. about the structure of Access databases, and there is no indication that 
  67. they are planning to change ("You either use VB/Access or we'll make you pay 
  68. through the ODBC monster!").  Sorry, I digress.  My recommendation, if you 
  69. absolutely MUST use Access, then use VB.  Otherwise, migrate your database 
  70. to a more open system (Paradox,dBase/FoxPro,anything you can get a native 
  71. engine), and use Delphi.
  72.  
  73. I hope this helps those who are still having problems accessing Access 
  74. databases via ODBC.  If I've left anything out, I would appreciate 
  75. commentary (no flames please...whine whine ;)
  76.  
  77. Good Luck!
  78. Lance Leverich
  79. PDA, Inc.
  80. lancel@pdainc.com
  81. (913) 469-8700 ext.4110
  82.  
  83.